package thinkingJava.chapter14;

import java.util.ArrayList;
import java.util.List;

public class ForNameCreater extends PetCreater {

	private static List<Class<? extends Pet>> types = new ArrayList<Class<? extends Pet>>();

	private static String[] typeNames =
		{
			"thinkingJava.chapter14.Mutt" ,
			"thinkingJava.chapter14.Pug",
			"thinkingJava.chapter14.EgyptianMau" ,
			"thinkingJava.chapter14.Manx",
			"thinkingJava.chapter14.Cymric" ,
			"thinkingJava.chapter14.Rat",
			"thinkingJava.chapter14.Mouse" ,
			"thinkingJava.chapter14.Hamster"
		};
	@SuppressWarnings("unchecked")
	private static void loader() {
		try {
			for (String name : typeNames) {
				types.add((Class<? extends Pet>)Class.forName(name));
			}
		} catch (ClassNotFoundException e) {
			throw new RuntimeException(e);
		}
	}
	static {
		loader();
	}
	public List<Class<? extends Pet>> types() {
		return types;
	}

}
